<?php
class Client_Model extends ORM {
	
	protected $table_name = 'clients';
	protected $primary_key = 'clients_id';
	protected $col_sort_order = 'clients_sort_order';
	protected $sorting = array('clients_sort_order' => 'asc');
	
	public function get()
	{
		$this->db->from($this->table_name);
		$this->db->select('*');
		$this->db->orderby($this->col_sort_order,'desc');
		$this->db->orderby($this->primary_key,'desc');
		$query = $this->db->get();
		return $query->result_array(false);
		
	}
	public function get_with_active()
	{
		$this->db->from($this->table_name);
		$this->db->select('*');
		$this->db->where('clients_status','1');
		$this->db->orderby('clients_name','ASC');
		//$this->db->orderby($this->primary_key,'desc');
		$query = $this->db->get();
		return $query->result_array(false);
		
	}
	public function count_row()
	{
		$this->db->select('COUNT('.$this->primary_key.') AS max');
		$this->db->from($this->table_name);
        $this->db->orderby($this->col_sort_order,'asc');
		$query = $this->db->get();
		return $query->result_array(false);
	}
	public function get_oder()
	{
		$this->db->from($this->table_name);
		$this->db->select($this->primary_key);
		$this->db->orderby($this->col_sort_order,'asc');
		$query = $this->db->get();
		return $query->result_array(false);
		
	}
	
}
?>